#ifndef __OPERATOR_H__
#define __OPERATOR_H__

#include <list>

enum TYPE { NONE = 0, NUMBER, BLOCK, FUNCTION };

/* memory block */
class Block {
	void *ptr;
	unsigned int size;
	public:
	Block() {
		ptr = NULL;
		size = 0;
	}
	Block(void* p, int s) {
		ptr = p;
		size = s;
	}

};


/** arguments **/
class Args;/** multiple values **/
/** Value abstraction: void/block/number/function **/
class Value;

/** Function is the form: Value func(Args) **/
typedef Value (*Function)(Args);


class Value {
	TYPE type;
public:
	double number;
	Block block;	
	Value (*function)(Args);

public:
	Value();	
	Value(double d); // number
	Value(void *p, int s); // block
	Value(Function f); // function

public:
	bool isNumber;
	bool isBlock;
	bool isFunction;		
};


class Args {

	std::list<Value> rawList;
public:
	
	/** return nth arg: O(n)**/
	Value get(int index) {
		int t = 0;
		for(std::list<Value>::iterator i = rawList.begin(); i != rawList.end(); ++i)
		{
			if(t == index)
				return *i;
			t++;
		}
	}
};

double toNumber(Value);
Function toFunction(Value);
Block toBlock(Value);

Value doNothing(Args a);

#endif
